class Solution {
public:
    int tribonacci(int n) {
            if(n <= 1) // 处理边界
                return n;
 
            int a = 0, b = 1, c = 1, d = 1; // 滚动数组思想优化空间
            for(int i = 3; i <= n; ++i)
            {
                d = a + b + c;
                a = b;
                b = c;
                c = d;
            }
            return d;
    }
};